package org.nobject.common.swing.g;

import java.util.Vector;

import javax.swing.table.DefaultTableModel;

import org.nobject.common.log.Log;

/**
 * GTableModel
 *
 * @author bianrongjun
 * @version 1.0
 */
public class GTableModel extends DefaultTableModel {
	
	/**
	 * columnClasses
	 */
	private Class[] columnClasses;
	
	/**
	 * getColumnIdentifiers
	 * @return
	 */
	public Vector getColumnIdentifiers(){
		return this.columnIdentifiers;
	}
	
	/**
	 * getData
	 * @return
	 */
	public Vector getDataVector(){
		return this.dataVector;
	}
	
	/**
	 * setDataVector
	 * @param dataVector
	 */
	public void setDataVector(Vector dataVector){
		setDataVector(dataVector,this.columnIdentifiers);
	}
	
	
	/**
	 * setColumnClass
	 * @param columnClasses
	 */
	public void setColumnClass(Class[] columnClasses){
		this.columnClasses=columnClasses;
	}
	
	/* (non-Javadoc)
	 * @see javax.swing.table.AbstractTableModel#getColumnClass(int)
	 */
	public Class<?> getColumnClass(int columnIndex) {
		if(columnClasses!=null){
			if(columnClasses.length>columnIndex)
				return columnClasses[columnIndex];
			else{
				Log.error("未找到列类型");
				return null;
			}
		}else{
			return super.getColumnClass(columnIndex);
		}
	}
	
}
